home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DBASE_UT
/
INDX18EU
/
OTHRTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-03-15
|
5KB
|
230 lines
PROGRAM OtherTests ;
{
Hi,
Before you run this test ( I hope ) you need to realize that
the times generated with the MarkTime and ElapsedTime are not very
acurate. I've receive times from 5 to 11 hundredths of a second for
all the below tests ( except the first which is always 0 ). There's
no good way to test times on a PC since Interupts will always "steal"
some of the time during processing. These times are meant to give you
a feel for how fast these routines are. Yes, Move is faster than
Exchange ( sometimes ), but the move option would require a thrid
variable of the same size to hold on of the values. Plus it would
require two statements to do one thing. I use it in Qwik sorts, ETC,
where a lot of swaping is needed and I don't want to be bothered with
declaring many temp variables.
}
USES
CRT ,
DOS ,
AsmRoutines ;
CONST
MAX_ARR = 60 * 1024 ;
TYPE
TLargeType = ARRAY [ 1 .. MAX_ARR ]
OF BYTE ;
PLargeType = ^TLargeType ;
VAR
h : WORD ;
m : WORD ;
s : WORD ;
hSec : WORD ;
PROCEDURE MarkTime ;
BEGIN { MarkTime }
GetTime ( h , m , s , hSec ) ;
END ; { MarkTime }
FUNCTION ElapsedTime : LONGINT ;
VAR
eh : WORD ;
em : WORD ;
es : WORD ;
ehSec : WORD ;
BEGIN { ElapsedTime }
GetTime ( eh , em , es , ehSec ) ;
ElapsedTime := ( ( eh - h ) * 60 * 60 * 100 ) +
( ( em - m ) * 60 * 100 ) +
( ( es - s ) * 100 ) +
( ehSec - hSec ) ;
END ; { ElapsedTime }
PROCEDURE BuildVar ( VAR arr : PLargeType ) ;
VAR
i : WORD ;
BEGIN { BuildVar }
New ( arr ) ;
FOR i := 1 TO MAX_ARR
DO
arr^[ i ] := Random ( 256 ) ; { 0 .. 255 }
END ; { BuildVar }
VAR
arr1 : PLargeType ;
arr2 : PLargeType ;
comp : INTEGER ;
ch : CHAR ;
t : LONGINT ;
BEGIN
Write ( 'Building two 60K vars...' ) ;
BuildVar ( arr1 ) ;
BuildVar ( arr2 ) ;
WriteLn ( '...done.' ) ;
WriteLn ;
WriteLn ;
Write ( 'Going to compare two 64K vars: [PRESS ANY KEY] ' ) ;
ch := ReadKey ;
WriteLn ;
Write ( 'arr1 is ' ) ;
MarkTime ;
comp := Compare ( arr1^ , arr2^ , FALSE , SizeOf ( arr1^ ) ) ;
t := ElapsedTime ;
CASE comp
OF
-1 : Write ( 'less than ' ) ;
0 : Write ( 'equal to ' ) ;
1 : Write ( 'greater than ' ) ;
ELSE
WriteLn ;
WriteLn ( 'ERROR! Invalid return from Compare!!' ) ;
Halt ( 12 ) ;
END ; { CASE comp }
WriteLn ( 'arr2. Took ' , t , ' hundredths of a second.' ) ;
WriteLn ;
WriteLn ;
Write ( 'Going to exchange two 64K vars: [PRESS ANY KEY] ' ) ;
ch := ReadKey ;
WriteLn ;
Write ( 'Exchanging to 60K variables now...' ) ;
MarkTime ;
Exchange ( arr1^ , arr2^ , SizeOf ( arr1^ ) ) ;
t := ElapsedTime ;
WriteLn ( 'DONE! Took ' , t , ' hundredths of a second.' ) ;
WriteLn ;
Write ( 'Using MOVE from TP would take ' ) ;
MarkTime ;
Move ( arr1^ , arr2^ , SizeOf ( arr1^ ) ) ;
Move ( arr1^ , arr2^ , SizeOf ( arr1^ ) ) ;
t := ElapsedTime ;
WriteLn ( t , ' hundredths of a second plus a third 60K VAR!' ) ;
WriteLn ;
WriteLn ;
Write ( 'Going to compare two 64K vars that are = : [PRESS ANY KEY] ' ) ;
ch := ReadKey ;
WriteLn ;
WriteLn ( 'Comparing two 60K vars that ARE equal: ' ) ;
Write ( 'arr1 is ' ) ;
MarkTime ;
comp := Compare ( arr1^ , arr2^ , FALSE , SizeOf ( arr1^ ) ) ;
t := ElapsedTime ;
CASE comp
OF
-1 : Write ( 'less than ' ) ;
0 : Write ( 'equal to ' ) ;
1 : Write ( 'greater than ' ) ;
ELSE
WriteLn ;
WriteLn ( 'ERROR! Invalid return from Compare!!' ) ;
Halt ( 12 ) ;
END ; { CASE comp }
WriteLn ( 'arr2. Took ' , t , ' hundredths of a second.' ) ;
Dispose ( arr1 ) ;
Dispose ( arr2 ) ;
END .